<?php
class DataWaitingConfirm{
	private $ConfirmCode;
	private $DateCreate;
	static function generate(){
		$obj = new DataWaitingConfirm();
		$obj->ConfirmCode = unpack('C*', UtilHash::generateKey( 10 )  ) ;
		$obj->DateCreate = microtime ();
		return $obj;
	}
	static function swap($bytebuffer){
		$obj = new DataWaitingConfirm();
		$obj->ConfirmCode = DataUtil::readBBin( $bytebuffer ) ;
		$obj->DateCreate = DataUtil::readInt32( $bytebuffer ) ;
		return $obj;
	}
	function getBinSize(){
		$size = 0;
		$size += 1  + count($this->ConfirmCode);
		$size += 4 ;
		return $size;
	}
	function getBinary(){
		$buf = ByteBuffer::allocate( $this->getBinSize() ) ;
		DataUtil::writeBBin( $buf , $this->ConfirmCode ) ;
		DataUtil::writeInt32( $buf , $this->DateCreate ) ;
		return  $buf ->_array() ;
	}
	function getCode(){
		return implode(array_map("chr",  $this->ConfirmCode )) ;
	}
	function getTime(){
		return $this->DateCreate;
	}
}
?>